﻿using System;
using System.Collections.Generic;

namespace Loki.Model
{
    public class EntityEqualityComparer<TEntityClass, TEntityKey> : EqualityComparer<TEntityClass> where TEntityClass : IKeyedEntity<TEntityKey>
    {
        public override bool Equals(TEntityClass x, TEntityClass y)
        {
            if (x == null || y == null)
            {
                return x == null;
            }
            else
            {
                return Object.Equals(x.ID, y.ID);
            }
        }

        public override int GetHashCode(TEntityClass obj)
        {
            return obj.ID.GetHashCode();
        }
    }
}